<!DOCTYPE html>
<meta charset="utf-8">
<title>import() inside compiled strings uses the script base URL inside a module script that is loaded from a file</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<div id="dummy"></div>

<script type="module">
function load(scriptSrc) {
  const el = document.createElement("script");
  el.type = "module";
  el.src = scriptSrc;
  document.body.appendChild(el);
}

function createTestPromise() {
  return new Promise((resolve, reject) => {
    window.dummyDiv.removeAttribute("onclick");
    delete window.evaluated_imports_a;
    delete window.label;

    window.continueTest = resolve;
    window.errorTest = reject;
  });
}

window.dummyDiv = document.querySelector("#dummy");

const evaluators = [
  "setTimeout",
  "eval",
  "Function",
  "reflected-inline-event-handlers",
  "inline-event-handlers-UA-code"
];

for (const label of evaluators) {
  promise_test(() => {
    const promise = createTestPromise();

    window.label = label;
    load(`scripts/${label}.js`);

    return promise.then(module => {
      assert_true(window.evaluated_imports_a, "The module must have been evaluated");
      assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct");
    });
  }, label + " should successfully import");
};
</script>
